package org.softmed.reflection.utils;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MapperConfig {

	Map<String, Class> fieldTypes = new HashMap<String, Class>();

	List<String> fieldNames = new ArrayList<String>();

	Map<String, Method> setters = new HashMap<String, Method>();

	Map<String, Method> getters = new HashMap<String, Method>();

	private Class type;

	public MapperConfig(Class type) {
		this.type = type;
	}

	public void addPair(String field, Class fieldType, Method getter,
			Method setter) {

		String fieldName = field.substring(0, 1);
		fieldName = fieldName.toLowerCase();
		fieldName += field.substring(1);

		fieldTypes.put(field, fieldType);
		fieldNames.add(fieldName);
		setters.put(fieldName, setter);
		getters.put(fieldName, getter);

	}

	public void listMethods() {

		System.out.println("Listing Mapper config for " + type);
		System.out.println("GETTERS");
		Collection<Method> gettersM = getters.values();
		for (Method getter : gettersM) {
			System.out.println(getter);
		}

		System.out.println("SETTERS");
		Collection<Method> settersM = setters.values();
		for (Method setter : settersM) {
			System.out.println(setter);
		}
		System.out.println("DONE");
	}

	public List<String> getFields() {
		return fieldNames;
	}

	public Map<String, Method> getGetters() {
		return getters;
	}

	public Map<String, Method> getSetters() {
		return setters;
	}

}
